package org.black.phoneUtility.sms.reply.app.fragment;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.black.phoneUtility.R;
import org.black.phoneUtility.app.activity.ContactGroupActivity;
import org.black.phoneUtility.sms.reply.SmsReplyConstant;
import org.black.phoneUtility.sms.reply.database.dataModel.NoneReplyNumber;
import org.black.phoneUtility.sms.reply.database.dataModel.NoneReplyNumberFromContact;
import org.black.phoneUtility.sms.reply.database.dataModel.NoneReplyNumberFromContacts;
import org.black.phoneUtility.sms.reply.database.dataModel.NoneReplyNumberFromMatchSmsWithKeyword;
import org.black.phoneUtility.sms.reply.database.dataModel.NoneReplyNumberFromNumbersFromContactGroup;
import org.black.phoneUtility.sms.reply.database.dataModel.NoneReplyNumberFromUserInput;
import org.black.phoneUtility.sms.reply.widget.NoneReplyNumberFromAdapter;

import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Fragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.util.Log;
import android.view.ActionMode;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView.MultiChoiceModeListener;
import android.widget.AdapterView;
import android.widget.ListView;

public class SmsReplyNoneReplyNumberFromListFragment extends Fragment {
	public static final String TAG = SmsReplyNoneReplyNumberFromListFragment.class
			.getName();
	public static final String LOG_TAG = SmsReplyNoneReplyNumberFromListFragment.class
			.getName();
	public static final String ARGUMENTS_SMS_REPLY_NONE_REPLY_LIST = "noneReplyNumberList";

	private NoneReplyNumberFromAdapter noneReplyNumberFromAdapter;
	private List<NoneReplyNumber> noneReplyNumbers;
	private ListView noneReplyNumbersListView;
	private AlertDialog.Builder forAskingDeleteSmsRepliesBuilder = null;
	private AlertDialog.Builder forAskingDeleteAllRecordsBuilder = null;

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// To hook action bar menu
		setHasOptionsMenu(true);
		this.noneReplyNumberFromAdapter = new NoneReplyNumberFromAdapter(
				getActivity());
		forAskingDeleteSmsRepliesBuilder = new AlertDialog.Builder(
				getActivity());
	}

	@Override
	public void onCreateContextMenu(ContextMenu menu, View v,
			ContextMenuInfo menuInfo) {
		super.onCreateContextMenu(menu, v, menuInfo);
	}

	@Override
	public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
		super.onCreateOptionsMenu(menu, inflater);
		inflater.inflate(R.menu.sms_reply_none_reply_number_from_list_actions,
				menu);
	}

	@SuppressWarnings("unchecked")
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		super.onCreateView(inflater, container, savedInstanceState);
		View result = inflater.inflate(
				R.layout.sms_none_reply_number_from_list, container, false);
		this.noneReplyNumbers = (List<NoneReplyNumber>) getArguments()
				.getSerializable(ARGUMENTS_SMS_REPLY_NONE_REPLY_LIST);
		this.noneReplyNumbersListView = (ListView) result
				.findViewById(R.id.smsNoneReplyNumberFromListView);

		View emptyView = result
				.findViewById(R.id.smsNoneReplyFromListViewNoDataTextView);
		this.noneReplyNumbersListView.setEmptyView(emptyView);
		this.noneReplyNumbersListView.setAdapter(noneReplyNumberFromAdapter);
		this.noneReplyNumberFromAdapter.setNoneReplyNumbers(noneReplyNumbers);
		this.noneReplyNumberFromAdapter.notifyDataSetChanged();
		this.noneReplyNumbersListView
				.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
		this.noneReplyNumbersListView
				.setMultiChoiceModeListener(new MultiChoiceModeListener() {
					private int numberChoose = 0;

					@Override
					public boolean onPrepareActionMode(ActionMode mode,
							Menu menu) {
						// TODO Auto-generated method stub
						return false;
					}

					@Override
					public void onDestroyActionMode(ActionMode mode) {
						noneReplyNumberFromAdapter.clearSelection();

					}

					@Override
					public boolean onCreateActionMode(ActionMode mode, Menu menu) {
						// TODO Auto-generated method stub
						numberChoose = 0;
						MenuInflater inflater = getActivity().getMenuInflater();
						inflater.inflate(
								R.menu.sms_reply_none_reply_number_from_choose_multi_items,
								menu);
						return true;
					}

					@Override
					public boolean onActionItemClicked(final ActionMode mode,
							MenuItem item) {
						switch (item.getItemId()) {

						case R.id.menu_sms_reply_none_reply_number_from_choose_multi_items_delete:
							forAskingDeleteSmsRepliesBuilder
									.setMessage(getString(
											R.string.sms_reply_none_reply_list_dialog_message_do_you_really_want_to_delete_numbers_settings,
											String.valueOf(numberChoose)));
							forAskingDeleteSmsRepliesBuilder.setPositiveButton(
									android.R.string.ok,
									new DialogInterface.OnClickListener() {

										@Override
										public void onClick(
												DialogInterface dialog,
												int which) {
											numberChoose = 0;
											noneReplyNumberFromAdapter
													.removeSelections();
											mode.finish();
										}
									}).setNegativeButton(
									android.R.string.cancel,
									new DialogInterface.OnClickListener() {

										@Override
										public void onClick(
												DialogInterface dialog,
												int which) {
										}
									});
							forAskingDeleteSmsRepliesBuilder.show();
							return true;

						}
						return false;
					}

					@Override
					public void onItemCheckedStateChanged(ActionMode mode,
							int position, long id, boolean checked) {
						if (checked) {
							numberChoose++;
							noneReplyNumberFromAdapter.addSelection(position,
									checked);
						} else {
							numberChoose--;
							noneReplyNumberFromAdapter
									.removeSelection(position);
						}
						mode.setTitle(String.valueOf(numberChoose));

					}
				});
		this.noneReplyNumbersListView
				.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

					@Override
					public boolean onItemLongClick(AdapterView<?> parent,
							View view, int position, long id) {
						noneReplyNumbersListView.setItemChecked(position,
								!noneReplyNumberFromAdapter
										.isPositionChecked(position));
						return false;
					}
				});
		this.noneReplyNumbersListView
				.setOnItemClickListener(new AdapterView.OnItemClickListener() {

					@Override
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {
						NoneReplyNumber noneReplyNumber = (NoneReplyNumber) noneReplyNumberFromAdapter
								.getItem(position);
						if (noneReplyNumber instanceof NoneReplyNumberFromMatchSmsWithKeyword) {
							SmsReplyAddEditMatchSmsKeywordDialogFragment smsReplyAddEditMatchSmsKeywordDialogFragment = new SmsReplyAddEditMatchSmsKeywordDialogFragment();
							Bundle bundle = new Bundle();
							bundle.putSerializable(
									SmsReplyAddEditMatchSmsKeywordDialogFragment.ARGUMENTS_SMS_REPLY_ADD_EDIT_MATCH_SMS_KEYWORDS_COME_FROM,
									SmsReplyAddEditMatchSmsKeywordDialogFragment.MATCH_SMS_KEYWORDS_COME_FROM_RESPONSE_NUMBER_FROM);
							bundle.putSerializable(
									SmsReplyAddEditMatchSmsKeywordDialogFragment.ARGUMENTS_SMS_REPLY_ADD_EDIT_MATCH_SMS_KEYWORDS_OBJECT,
									noneReplyNumber);
							smsReplyAddEditMatchSmsKeywordDialogFragment
									.setArguments(bundle);
							smsReplyAddEditMatchSmsKeywordDialogFragment
									.show(getFragmentManager(),
											SmsReplyAddEditMatchSmsKeywordDialogFragment.TAG);
						}

					}
				});
		this.forAskingDeleteAllRecordsBuilder = new AlertDialog.Builder(
				getActivity());
		this.forAskingDeleteAllRecordsBuilder
				.setMessage(R.string.sms_reply_response_number_from_list_dialog_message_do_you_really_want_to_delete_all_settings);
		this.forAskingDeleteAllRecordsBuilder.setPositiveButton(
				android.R.string.ok, new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						noneReplyNumberFromAdapter.remove(noneReplyNumbers);
						Log.i(LOG_TAG, "Delete all sms none reply records");
					}
				}).setNegativeButton(android.R.string.cancel,
				new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {

					}

				});
		return result;
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		noneReplyNumberFromAdapter = null;
		noneReplyNumbers = null;
		noneReplyNumbersListView = null;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			getActivity().onBackPressed();
			return true;
		case R.id.menu_sms_reply_none_reply_number_from_list_add:
			SmsReplyNoneReplyNumberAddNumberDialogFragment smsReplyNoneReplyNumberAddNumberDialogFragment = new SmsReplyNoneReplyNumberAddNumberDialogFragment();
			Bundle bundle = new Bundle();
			smsReplyNoneReplyNumberAddNumberDialogFragment.setArguments(bundle);
			smsReplyNoneReplyNumberAddNumberDialogFragment.show(
					getFragmentManager(),
					SmsReplyNoneReplyNumberAddNumberDialogFragment.TAG);
			return true;
		case R.id.menu_sms_reply_none_reply_number_from_clear_all:
			this.forAskingDeleteAllRecordsBuilder.show();
			return true;
		default:
			return super.onOptionsItemSelected(item);
		}
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		getActivity().setTitle(
				getString(R.string.sms_add_edit_none_reply_number_from_title));

		getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
		getActivity().getActionBar().setTitle(
				getString(R.string.sms_add_edit_none_reply_number_from_title));
		getActivity().getActionBar().setDisplayOptions(
				ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE
						| ActionBar.DISPLAY_SHOW_HOME);
	}

	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if (data != null) {
			if (requestCode == SmsReplyConstant.REQUEST_CODE_NONE_REPLY_NUMBER_PICK_CONTENT) {
				if (resultCode == Activity.RESULT_OK) {
					Uri responseChooseUri = data.getData();
					this.handleChooseFromContact(responseChooseUri);
				}
			} else if (requestCode == SmsReplyConstant.REQUEST_CODE_NONE_REPLY_LIST_FROM_PICK_CONTACT_GROUP_CONTENT) {
				Uri groupUri = data.getData();
				this.handleChooseFromNumberFromContactGroup(groupUri);

			} else {
				Log.e(LOG_TAG,
						"resultCode does not match anyting! resultCode: "
								+ requestCode);
			}
		}
	}

	public void onChooseNoneReplyNumberFromAllInMyContacts() {
		NoneReplyNumberFromContacts noneReplyNumberFromContacts = new NoneReplyNumberFromContacts();
		noneReplyNumberFromContacts.setCreationDateTime(new Date());
		this.noneReplyNumberFromAdapter.add(noneReplyNumberFromContacts);
	}

	public void onChooseNoneReplyNumberFromContact() {
		Intent intent = new Intent(Intent.ACTION_PICK,
				ContactsContract.Contacts.CONTENT_URI);
		startActivityForResult(intent,
				SmsReplyConstant.REQUEST_CODE_NONE_REPLY_NUMBER_PICK_CONTENT);
	}

	public void onChooseNoneReplyNumberFromNumbersFromContactGroup() {
		Intent intent = new Intent(Intent.ACTION_PICK);
		intent.setClass(getActivity(), ContactGroupActivity.class);
		startActivityForResult(
				intent,
				SmsReplyConstant.REQUEST_CODE_NONE_REPLY_LIST_FROM_PICK_CONTACT_GROUP_CONTENT);
	}

	private void handleChooseFromContact(Uri contactUri) {
		new AsyncTask<Uri, Void, List<NoneReplyNumber>>() {

			@Override
			protected void onPostExecute(List<NoneReplyNumber> result) {
				super.onPostExecute(result);
				if (result != null) {
					noneReplyNumberFromAdapter.add(result);
				} else {
					SmsReplyNoNumberInContactDialogFragment smsReplyNoNumberInContactDialogFragment = new SmsReplyNoNumberInContactDialogFragment();
					smsReplyNoNumberInContactDialogFragment.show(getActivity()
							.getFragmentManager(),
							SmsReplyNoNumberInContactDialogFragment.TAG);
				}
				getView().findViewById(
						R.id.smsNoneReplyListLoadingPanelLinearLayout)
						.setVisibility(View.GONE);
				getView().findViewById(R.id.smsNoneReplyNumberFromListView)
						.setVisibility(View.VISIBLE);
			}

			@Override
			protected void onPreExecute() {
				super.onPreExecute();
				getView().findViewById(
						R.id.smsNoneReplyListLoadingPanelLinearLayout)
						.setVisibility(View.VISIBLE);
				getView().findViewById(R.id.smsNoneReplyNumberFromListView)
						.setVisibility(View.GONE);
			}

			@Override
			protected List<NoneReplyNumber> doInBackground(Uri... params) {
				Uri contactUri = params[0];
				Cursor contactIdCursor = getActivity()
						.getContentResolver()
						.query(contactUri,
								new String[] { ContactsContract.Contacts._ID,
										ContactsContract.Contacts.DISPLAY_NAME },
								ContactsContract.Contacts.HAS_PHONE_NUMBER
										+ " = ?",
								new String[] { String.valueOf(1) }, null);
				if (contactIdCursor != null
						&& contactIdCursor.moveToFirst() == true) {
					String id = contactIdCursor
							.getString(contactIdCursor
									.getColumnIndexOrThrow(ContactsContract.Contacts._ID));

					String displayName = contactIdCursor
							.getString(contactIdCursor
									.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));

					if (contactIdCursor != null) {
						try {
							contactIdCursor.close();
						} catch (Throwable t) {
							Log.e(LOG_TAG, "Fail to close contactIdCursor", t);
						}
					}
					Cursor phoneNumberCursor = getActivity()
							.getContentResolver()
							.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
									new String[] { ContactsContract.CommonDataKinds.Phone.NUMBER },
									ContactsContract.CommonDataKinds.Phone.CONTACT_ID
											+ " = ?", new String[] { id }, null);
					List<String> phones = new ArrayList<String>();
					phoneNumberCursor.moveToFirst();
					do {
						phones.add(phoneNumberCursor.getString(phoneNumberCursor
								.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
					} while (phoneNumberCursor.moveToNext());
					if (phoneNumberCursor != null) {
						try {
							phoneNumberCursor.close();
						} catch (Throwable t) {
							Log.e(LOG_TAG, "Fail to close phoneNumberCursor!",
									t);
						}
					}

					List<NoneReplyNumber> noneReplyNumbers = new ArrayList<NoneReplyNumber>();
					for (String phone : phones) {
						if (PhoneNumberUtils.isWellFormedSmsAddress(phone)) {
							NoneReplyNumberFromContact noneReplyNumberFromContact = new NoneReplyNumberFromContact();
							noneReplyNumberFromContact.setName(displayName);
							noneReplyNumberFromContact.setPhoneNumber(phone);
							noneReplyNumberFromContact
									.setCreationDateTime(new Date());
							noneReplyNumbers.add(noneReplyNumberFromContact);
						}
					}
					return noneReplyNumbers;
				} else {
					return null;
				}
			}

		}.execute(contactUri);

	}

	private void handleChooseFromNumberFromContactGroup(Uri groupUri) {
		new AsyncTask<Uri, Void, List<NoneReplyNumber>>() {

			@Override
			protected void onPostExecute(List<NoneReplyNumber> result) {
				super.onPostExecute(result);
				if (result != null && result.size() > 0) {
					noneReplyNumberFromAdapter.add(result);
				} else {
					SmsReplyNoNumberInContactDialogFragment smsReplyNoNumberInContactDialogFragment = new SmsReplyNoNumberInContactDialogFragment();
					smsReplyNoNumberInContactDialogFragment.show(getActivity()
							.getFragmentManager(),
							SmsReplyNoNumberInContactDialogFragment.TAG);
				}
				getView().findViewById(
						R.id.smsNoneReplyListLoadingPanelLinearLayout)
						.setVisibility(View.GONE);
				getView().findViewById(R.id.smsNoneReplyNumberFromListView)
						.setVisibility(View.VISIBLE);
			}

			@Override
			protected void onPreExecute() {
				super.onPreExecute();
				getView().findViewById(
						R.id.smsNoneReplyListLoadingPanelLinearLayout)
						.setVisibility(View.VISIBLE);
				getView().findViewById(R.id.smsNoneReplyNumberFromListView)
						.setVisibility(View.GONE);
			}

			@Override
			protected List<NoneReplyNumber> doInBackground(Uri... params) {
				Uri groupUri = params[0];
				Cursor queryGroupCursor = null;
				try {
					queryGroupCursor = getActivity().getContentResolver()
							.query(groupUri,
									new String[] { ContactsContract.Groups._ID,
											ContactsContract.Groups.TITLE },
									null, null, null);
					if (queryGroupCursor != null
							&& queryGroupCursor.moveToFirst() == true) {
						long groupId = queryGroupCursor
								.getLong(queryGroupCursor
										.getColumnIndexOrThrow(ContactsContract.Groups._ID));
						String groupTitle = queryGroupCursor
								.getString(queryGroupCursor
										.getColumnIndex(ContactsContract.Groups.TITLE));
						if (groupId != -1l) {
							Cursor groupMembershipCursor = null;
							try {
								groupMembershipCursor = getActivity()
										.getContentResolver()
										.query(ContactsContract.Data.CONTENT_URI,
												new String[] { ContactsContract.CommonDataKinds.GroupMembership.CONTACT_ID },
												ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID
														+ " = ? ",
												new String[] { String
														.valueOf(groupId) },
												null);
								if (groupMembershipCursor != null
										&& groupMembershipCursor.moveToFirst() == true) {
									List<Long> contactIds = new ArrayList<Long>();
									do {
										contactIds
												.add(groupMembershipCursor
														.getLong(groupMembershipCursor
																.getColumnIndex(ContactsContract.CommonDataKinds.GroupMembership.CONTACT_ID)));
									} while (groupMembershipCursor.moveToNext() == true);

									if (contactIds.size() > 0) {
										List<NoneReplyNumber> noneReplyNumbersFromContactGroup = new ArrayList<NoneReplyNumber>();
										for (Long contactId : contactIds) {
											Cursor contactCursor = null;
											try {
												contactCursor = getActivity()
														.getContentResolver()
														.query(ContactsContract.Contacts.CONTENT_URI,
																new String[] { ContactsContract.Contacts.DISPLAY_NAME },
																ContactsContract.Contacts.HAS_PHONE_NUMBER
																		+ " = ? "
																		+ " AND "
																		+ ContactsContract.Contacts._ID
																		+ " = ? ",
																new String[] {
																		String.valueOf(1),
																		String.valueOf(contactId) },
																null);
												if (contactCursor != null
														&& contactCursor
																.moveToFirst() == true) {
													String displayName = contactCursor
															.getString(contactCursor
																	.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
													Cursor cursorForQueryPhoneNumber = null;
													try {
														cursorForQueryPhoneNumber = getActivity()
																.getContentResolver()
																.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
																		new String[] { ContactsContract.CommonDataKinds.Phone.NUMBER },
																		ContactsContract.CommonDataKinds.Phone.CONTACT_ID
																				+ " = ? ",
																		new String[] { String
																				.valueOf(contactId) },
																		null);
														List<String> phones = new ArrayList<String>();
														if (cursorForQueryPhoneNumber
																.moveToFirst() == true) {
															do {
																phones.add(cursorForQueryPhoneNumber
																		.getString(cursorForQueryPhoneNumber
																				.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
															} while (cursorForQueryPhoneNumber
																	.moveToNext() == true);
															for (String phone : phones) {
																if (PhoneNumberUtils
																		.isWellFormedSmsAddress(phone)) {
																	NoneReplyNumberFromNumbersFromContactGroup noneReplyNumberFromNumbersFromContactGroup = new NoneReplyNumberFromNumbersFromContactGroup();
																	noneReplyNumberFromNumbersFromContactGroup
																			.setName(displayName);
																	noneReplyNumberFromNumbersFromContactGroup
																			.setPhoneNumber(phone);
																	noneReplyNumberFromNumbersFromContactGroup
																			.setCreationDateTime(new Date());
																	noneReplyNumberFromNumbersFromContactGroup
																			.setGroupName(groupTitle);
																	noneReplyNumbersFromContactGroup
																			.add(noneReplyNumberFromNumbersFromContactGroup);
																}
															}
														}
													} catch (Throwable throwable) {
														Log.e(LOG_TAG,
																"Error on querying phone.",
																throwable);
													} finally {
														if (cursorForQueryPhoneNumber != null) {
															try {
																cursorForQueryPhoneNumber
																		.close();
															} catch (Throwable th) {
																Log.e(LOG_TAG,
																		"Fail to close cursorForQueryPhoneNumber",
																		th);
															}
														}

													}

												}
											} catch (Throwable throwable) {
												Log.e(LOG_TAG,
														"Error on querying contact.",
														throwable);
											} finally {
												if (contactCursor != null) {
													try {
														contactCursor.close();
													} catch (Throwable th) {
														Log.e(LOG_TAG,
																"Fail to close contactCursor",
																th);
													}
												}
											}
										}
										return noneReplyNumbersFromContactGroup;
									}
								}
							} catch (Throwable throwable) {
								Log.e(LOG_TAG,
										"Error on querying group member ship.",
										throwable);
							} finally {
								if (groupMembershipCursor != null) {
									try {
										groupMembershipCursor.close();
									} catch (Throwable th) {
										Log.e(LOG_TAG,
												"Fail to close groupMembershipCursor",
												th);
									}
								}
							}
						}

					} else {
						Log.e(LOG_TAG,
								"Group should exist. However, can not move cursor to fist! Serious problem!");
					}
				} catch (Throwable throwable) {
					Log.e(LOG_TAG, "Error on querying group id.", throwable);
				} finally {
					if (queryGroupCursor != null) {
						try {
							queryGroupCursor.close();
						} catch (Throwable th) {
							Log.e(LOG_TAG,
									"Fail to close cursorForQueryGroupId", th);
						}
					}
				}
				return null;

			}

		}.execute(groupUri);
	}

	public void handleChooseFromUserInput(String phoneNumber) {
		if (PhoneNumberUtils.isWellFormedSmsAddress(phoneNumber)) {
			NoneReplyNumberFromUserInput noneReplyNumberFromUserInput = new NoneReplyNumberFromUserInput();
			noneReplyNumberFromUserInput.setCreationDateTime(new Date());
			noneReplyNumberFromUserInput.setPhoneNumber(phoneNumber);
			this.noneReplyNumberFromAdapter.add(noneReplyNumberFromUserInput);
		} else {
			// TODO
		}

	}

	public void handleAddChooseFromMatchMessageWithKeywords(String keyword) {
		if (TextUtils.isEmpty(keyword) == false) {
			NoneReplyNumberFromMatchSmsWithKeyword noneReplyNumberFromMatchSmsWithKeyword = new NoneReplyNumberFromMatchSmsWithKeyword();
			noneReplyNumberFromMatchSmsWithKeyword
					.setCreationDateTime(new Date());
			noneReplyNumberFromMatchSmsWithKeyword.setKeyword(keyword);
			this.noneReplyNumberFromAdapter
					.add(noneReplyNumberFromMatchSmsWithKeyword);
		} else {

		}

	}

	public void handleUpdateChooseFromMatchMessageWithKeywords() {
		this.noneReplyNumberFromAdapter.notifyDataSetChanged();
	}
}
